package org.zbus.thrift;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;

import com.alibaba.fastjson.JSON;

public class ThriftClient {
	public static void main(String[] args) throws Exception {
		
		TFramedTransport transport = new TFramedTransport(
				new TSocket("localhost", 25555));
		transport.open();
		
		TBinaryProtocol proto = new TBinaryProtocol(transport);  
		
		ZbusApi.Client client = new ZbusApi.Client(proto);
		 
		Map<String, Object> req = new HashMap<String, Object>();
		req.put("method", "getString");
		req.put("params", Arrays.asList("xxxyyy")); //必须是参数数组,元素类型不限
		//req.put("module", ""); 
		
		String reqJsonString = JSON.toJSONString(req);
		
		for(int i=0;i<10000;i++){ 
			String res = client.rpc("MyRpc", reqJsonString);
			System.out.println(res); 
		}
		transport.close();
	}
}
